<?php
// +-------------------------------------------------------------
// | Name: 星空框架  收货地址验证规则
// +-------------------------------------------------------------
// | Version: V5.0
// +-------------------------------------------------------------
// | Author: xkyinzhe <zhonghuaxinxing@sina.cn>
// +-------------------------------------------------------------
// | Time: 2021-05-10 15:28
// +-------------------------------------------------------------
declare(strict_types=1);

namespace app\common\validate;

use think\Validate;

/**
 * @xk 收货地址模型
 */
class Address extends Validate
{

  protected $rule = [
    'address_id' => 'require|number|>=:1',
    'user_sn' => 'require',
    'name' => 'require',
    'tel' => 'mobile',
    'province' => 'require',
    'province_code' => 'require',
    // 'city' => 'require',
    // 'city_code' => 'require',
    // 'area' => 'require',
    // 'area_code' => 'require',
    'address' => 'require|chsDash',
  ];
  protected $message = [
    'address_id.number|>=:1' => '请选择需要修改的地址',
    'user_sn.require' => '您还没有登陆，请先登陆',
    'name.require' => '请填写姓名',
    'tel.mobile' => '请填写正确的手机号码',
    'province.require' => '请选择省',
    'province_code.require' => '请选择省，传输省编码',
    // 'city.require' => '请选择市',
    // 'city_code.require' => '请选择市，传输市编码',
    // 'area.require' => '请选择区',
    // 'area_code.require' => '请选择区，传输区编码',
    'address.require' => '请填写正确的地址',
    'address.chsDash' => '请输入格式正确的详细地址',
  ];
  protected $scene = [
    'create' => ['user_sn','name','tel','province','province_code','address'],
    'edit' => ['address_id','user_sn','name','tel','province','province_code','address'],
    'chanageDefault' => ['address_id'],
    'delete' => ['address_id','user_sn']
  ];
}
